<?php

namespace app\admin\controller;

use app\common\model\Admin;
use think\Controller;
use think\Request;

class Index extends Controller
{
    /**
     * @return \think\response\View
     */

    public function login(){
        if (request()->isPost()) {
            $data = [
                'username' => input('post.username'),
                'password' => input('post.password')
            ];
            $result = model('Admin')->login($data);
            if ($result == 1) {
                $this->success('登录成功', 'admin/home/index');
            } else {
                $this->error($result);
            }
        }
        return view();
    }
}

//    public function index(){
//        if (request()->isPost()) {
//            $data = [
//                'username' => input('post.username'),
//                'password' => input('post.password')
//            ];
//            $result = model('Admin')->login($data);
//            if ($result == 1) {
//                $this->success('登录成功', 'admin/home/index');
//            } else {
//                $this->error($result);
//            }
//        }
//        return view();
//    }
